package com.cwz.logo;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import android.widget.SimpleAdapter;

public class GetDataThread extends Thread {

	private List<HashMap<String, Object>> listItem;
	private Receive receive;
	private SimpleAdapter adapter;
	public GetDataThread(List<HashMap<String, Object>> listItem,SimpleAdapter adapter,Receive receive) {
		this.listItem = listItem;
		this.receive = receive;
		this.adapter = adapter;
	}

	public void run() {
//		try {
//			Thread.sleep(5000);
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
		
		DataProvider.getData();
		Map<String, String> dataMap = DataProvider.getMap();
		Set<Entry<String, String>> set = dataMap.entrySet();
		Iterator<Entry<String, String>> it = set.iterator();
		while (it.hasNext()) {
			Entry<String, String> entry = it.next();
			//String title = entry.getKey();
			String url = entry.getValue();

			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("ItemImage", url);
			// map.put("ItemTitle", title);
			listItem.add(map);
		}
		LogoRunnable runnable = new LogoRunnable(listItem,adapter);
		receive.onReceived(runnable);
		
	}

}
